package syf.singlelist;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class test01 {
    @Test
    public void test01(){
        String config="SingleList/wuxu/applicationContext.xml";
        ApplicationContext ac=new ClassPathXmlApplicationContext(config);
        String config1="SingleList/wuxu/appli.xml";
        ApplicationContext acc=new ClassPathXmlApplicationContext(config1);
        SingleLinkList l= (SingleLinkList) ac.getBean("singleLinkList");
//        HeroNode node=new HeroNode(1,"孙悟空","斗战神佛");
//        HeroNode node1=new HeroNode(3,"孙悟空1","斗战神佛4");
//        HeroNode node2=new HeroNode(2,"孙悟空2","斗战神佛5");
//        HeroNode node3=new HeroNode(4,"孙悟空3","斗战神佛6");
//        l.addNode(node);
//        l.addNode(node1);
//        l.addNode(node2);
//        l.addNode(node3);
        HeroNode node= (HeroNode) acc.getBean("hero");
        HeroNode node1=(HeroNode) acc.getBean("hero1");
        HeroNode node2=(HeroNode) acc.getBean("hero2");
        HeroNode node3=(HeroNode) acc.getBean("hero3");
        HeroNode node50=new HeroNode(50,"","");
        l.PrintK(1);
        l.addNodeByOrder(node);
        l.addNodeByOrder(node1);
        l.addNodeByOrder(node2);
        l.addNodeByOrder(node3);
        l.addNodeByOrder(node50);
        l.PrintList();
        System.out.println( l.PrintCount() );
        HeroNode node4=new HeroNode(2,"沙僧","沙悟净");
        System.out.println();
        l.Modify(node1);
        l.Delete(node1);
        l.PrintList();
        System.out.println( l.PrintCount() );
        l.PrintK(1);
        l.reverseHead();
        l.PrintList();
        l.reverseHead();
        HeroNode h=new HeroNode(0,"","");
        SingleLinkList ll= new SingleLinkList(h);
        HeroNode node22=(HeroNode) acc.getBean("hero4");
        HeroNode node33=(HeroNode) acc.getBean("hero5");
        ll.addNode(node22);
        ll.addNode(node33);
        System.out.println("合并之后的列表");
        ll.converge(l.getHead());
        ll.PrintList();
        System.out.println("双向链表");
    }
}
